cairo_restore (cr);
}
+
+static AtkAttributeSet *
+add_attribute (AtkAttributeSet *attributes,
+ AtkTextAttribute attr,
+ const gchar *value)
+{
+ AtkAttribute *at;
+
+ at = g_new (AtkAttribute, 1);
+ at->name = g_strdup (atk_text_attribute_get_name (attr));
+ at->value = g_strdup (value);
+
+ return g_slist_prepend (attributes, at);
+}
+
+/*
+ * _gtk_style_context_get_attributes:
+ * @attributes: a #AtkAttributeSet to add attributes to
+ * @context: the #GtkStyleContext to get attributes from
+ * @flags: the state to use with @context
+ *
+ * Adds the foreground and background color from @context to
+ * @attributes, after translating them to ATK attributes.
+ *
+ * This is a convenience function that can be used in
+ * implementing the #AtkText interface in widgets.
+ *
+ * Returns: the modified #AtkAttributeSet
+ */
+AtkAttributeSet *
+_gtk_style_context_get_attributes (AtkAttributeSet *attributes,
+ GtkStyleContext *context,
+ GtkStateFlags flags)
+{
+ GdkRGBA color;
+ gchar *value;
+
+ gtk_style_context_get_background_color (context, flags, &color);
+ value = g_strdup_printf ("%u,%u,%u",
+ (guint) ceil (color.red * 65536 - color.red),
+ (guint) ceil (color.green * 65536 - color.green),
+ (guint) ceil (color.blue * 65536 - color.blue));
+ attributes = add_attribute (attributes, ATK_TEXT_ATTR_BG_COLOR, value);
+ g_free (value);
+
+ gtk_style_context_get_color (context, flags, &color);
+ value = g_strdup_printf ("%u,%u,%u",
+ (guint) ceil (color.red * 65536 - color.red),
+ (guint) ceil (color.green * 65536 - color.green),
+ (guint) ceil (color.blue * 65536 - color.blue));
+ attributes = add_attribute (attributes, ATK_TEXT_ATTR_FG_COLOR, value);
+ g_free (value);
+
+ return attributes;
+}
#include <gtk/gtkstyleprovider.h>
#include <gtk/gtkwidgetpath.h>
#include <gtk/gtkborder.h>
+#include <atk/atk.h>
G_BEGIN_DECLS
gdouble x,
gdouble y);
+/* Accessibility support */
+AtkAttributeSet *_gtk_style_context_get_attributes (AtkAttributeSet *attributes,
+ GtkStyleContext *context,
+ GtkStateFlags flags);
+
G_END_DECLS
#endif /* __GTK_STYLE_CONTEXT_H__ */